package com.medicine.product.utils;

import com.medicine.product.entity.Student;

import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

/**
 * @author lynn
 * @version 1.0
 * @date 2021/11/29
 */
public class Test implements Runnable{


    public static void main(String[] args) {

        Map<String,String> map = new HashMap<>(20);

        /*String str = "强力清除广告，上（网更）快的浏览器！搞什么飞机嘛。我去；";
        String[] regs = { "！", "，", "。", "；", "!", ",", ".", ";" };
        for ( int i = 0; i < regs.length / 2; i++ )
        {
            str = str.replaceAll (regs[i], regs[i + regs.length / 2]);
        }
        System.out.println (str);*/

        /*List<Student> students = new ArrayList<>(16);
        students.add(new Student("1", "张三", 18, "male", 88));
        students.add(new Student("2", "李四", 17, "male", 60));
        students.add(new Student("3", "王五", 18, "male", 100));
        students.add(new Student("4", "赵六", 20, "male", 10));
        students.add(new Student("5", "董七", 14, "female", 95));
        students.add(new Student("6", "幺八", 21, "male", 55));
        students.add(new Student("7", "老九", 20, "female", 66));
        students.add(new Student("8", "小明", 18, "male", 100));
        students.add(new Student("9", "小红", 22, "female", 95));
        students.add(new Student("10", "小张", 25, "male", 90));

        // 过滤出成绩100分的学生
        students =
                students.stream().filter(student -> student.getScore() == 100||student.getScore()==95).collect(Collectors.toList());
        students.forEach(System.out::println);*/

        /*double d=124.00;
        DecimalFormat df=new DecimalFormat(".00");
        System.out.println(df.format(d));

        Map<String,Object> ha = new HashMap<>();*/

        /*ClassLoader loader = Thread.currentThread().getContextClassLoader();
        System.out.println(loader);
        System.out.println(loader.getParent());
        System.out.println(loader.getParent().getParent());

        List<String> list = new ArrayList<>();
        list. add("x");
        Collection<String> clist = Collections. unmodifiableCollection(list);
        clist. add("y"); // 运行时此行报错
        System. out. println(list. size());*/

        /*ExecutorService pool = Executors.newFixedThreadPool(2);
        pool.submit(new Test());

        pool.shutdown();*/

        /*ThreadPoolExecutor pool = new ThreadPoolExecutor(10,10,100, TimeUnit.MILLISECONDS,new LinkedBlockingDeque<Runnable>(10));
        pool.execute(new Test());

        pool.shutdown();

        ReentrantLock lock = new ReentrantLock();
        lock.lock();

        lock.unlock();*/

        List<OOMObject> list = new ArrayList<OOMObject>();
        while (true){
            list.add(new OOMObject());
        }


    }

    static class OOMObject{

    }

    @Override
    public void run() {
        for (int x=0;x<100;x++){
            System.out.println(Thread.currentThread().getName()+":"+x);
        }
    }
}
